<?php
class rooms extends ujn_controller {
	var $auto_render = false;
	
	public function lists() {
		$data = array(
			'flag' => 1,
			'lists' => mdl_global_rooms::getInstance()->getAll(),
		);
		echo json_encode( $data );
	}
	
	public function get(){
		$data = array(
			'flag' => 1,
			'lists' => mdl_global_rooms::getInstance()->getOne( $_POST['tid'] ),
		);
		echo json_encode($data);
	}
	
	public function add() {
		$data = array(
			'flag' => mdl_global_rooms::getInstance()->add($_POST['name'], $_POST['maxplayers'], $_POST['drunk_type'], $_POST['drunk_degree'], $_POST['stake']), 
		);
		echo json_encode( $data );
	}
	
	public function edit() {
		$data = array(
			'flag' => mdl_global_rooms::getInstance()->edit($_POST['name'], $_POST['maxplayers'], $_POST['drunk_type'], $_POST['drunk_degree'], $_POST['stake'], $_POST['level'], $_POST['switch'], $_POST['tid']), 
		);
		echo json_encode( $data );							
	}
}